import { toast, to, err, set } from './uniapi';
export async function request(path: string, data: any) {
	try {
		const res = await wx.cloud.callContainer({
			config: {
				env: 'prod-0gg6hnwgf8f69aeb'
			},
			path,
			method: 'post',
			header: {
				'X-WX-SERVICE': 'dev-ymk-order'
			},
			data
		});
		if (data.scope === 'mop' && res.data.respCode === 410) {
			toast(res.data.msg);
			setTimeout(() => {
				to('/pages/store/store');
			}, 1000);
		}
		if (data.scope === 'mop' && res.data.respCode === 200) {
			set('token', res.data.token);
		}
		return res.data;
	} catch (error) {
		err(error);
		throw error;
	}
}
